liste = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8]

inversion = True

while (inversion == True):
    inversion = False
    i = 0
    while (i < len(liste)-1):
        if (liste[i] > liste[i+1]):
            liste[i:i+2] = [liste[i+1],liste[i]]
            inversion = True
        i = i + 1
print(liste)